<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>响应式导航栏</title>
    <script src="./js/jquery.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            min-width: 320px;
        }

        nav {
            border: 1px solid aqua;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: relative;
            padding: 0 20px;
        }

        nav .logo {
            cursor: pointer;
        }

        nav ul#nav_ul {
            display: block;
        }

        nav ul#nav_ul li {
            list-style: none;
            display: inline-block;
            padding: 10px 10px;
            cursor: pointer;
            border-radius: 20px;
            width: 70px;
            text-align: center;
        }

        nav ul#nav_ul li:hover {
            color: lightblue;
            background: cornflowerblue;
        }

        nav ul#nav_ul li.actived {
            color: white;
            background: cornflowerblue;
        }

        nav #menu_icon {
            display: none;
        }

        @media screen and (max-width: 980px) {
            nav ul#nav_ul {
                display: none;
                width: 100%;
                position: absolute;
                z-index: 999;
                top: 60px;
                left: 0;
            }

            nav ul#nav_ul li {
                display: block;
                border: 1px solid aqua;
                border-radius: 5px;
                background: lightslategray;
                width: 100%;
                color: white;
            }

            nav #menu_icon {
                display: inline-block;
                cursor: pointer;
            }
        }

        @media screen and (min-width: 981px) {
            nav ul#nav_ul {
                display: block !important;
            }
        }
    </style>
</head>

<body>
    <nav>
        <img class="logo" src="./images/logo.png" alt="">
        <ul id="nav_ul">
            <li class="actived">首页</li>
            <li>关于我们</li>
            <li>服务</li>
            <li>联系我们</li>
        </ul>
        <img id="menu_icon" src="./images/menu.png" alt="">
    </nav>
    <script>
        let menu_icon = $("#menu_icon");
        let nav_ul = $("#nav_ul");
        $("#menu_icon").click(function () {
            $("#nav_ul").toggle();
        });
        $("#nav_ul li").click(function () {
            $("#nav_ul li").removeClass("actived");
            $(this).addClass("actived");
        });
    </script>
</body>

</html>